Low-cost nonvolatile memories such as for example NAND-type flash memories suitable for storing a large amount of data have recently been widely used in household electrical appliances, portable electronic devices, and electronic devices such as memory cards and the like. When a system failure caused by a power failure, a malfunction or the like occurs in an electronic device having a flash memory, for example, part of data stored in the flash memory can be destroyed. As one method for protecting data from such a system failure, redundancy is provided to data written to the flash memory using a check sum or CRC (Cyclic Redundancy Check) code, for example, and a check sum is calculated from the data stored in the flash memory at a time of system restoration by turning on power to determine whether or not there is abnormality in the data.
As another method for data protection, an auxiliary nonvolatile memory capable of writing at higher speed than the flash memory is provided in addition to the flash memory, and the auxiliary nonvolatile memory stores bus information on a predetermined number of latest states of operation (statuses). FIG. 1 is a block diagram schematically showing a configuration of an electronic device having such a conventional flash memory. In FIG. 1, reference numeral 101 denotes the electronic device; reference numeral 102 denotes a CPU; reference numeral 103 denotes the flash memory provided as a main memory; reference numeral 104 denotes an auxiliary nonvolatile memory capable of writing at higher speed than the flash memory; reference numeral 105 denotes a bus for connecting the CPU 102 with the flash memory 103; reference numeral 106 denotes a bus branched off from the bus 105 and connected to the auxiliary nonvolatile memory 104; and reference numeral 107 denotes a signal line for supplying a control signal to the auxiliary nonvolatile memory 104.
Operation of the electronic device shown in FIG. 1 will next be described. For example, the CPU 102 supplies a control signal to the auxiliary nonvolatile memory 104 in a first half of each operation period of the flash memory 103, and the auxiliary nonvolatile memory 104 records information on the bus 105 via the bus 106 in response to the control signal. The auxiliary nonvolatile memory 104 records the bus information on only a plurality of latest statuses of statuses occurring in data writing, reading, erasing and other processing. The auxiliary nonvolatile memory 104 therefore does not need a very high storage capacity. Thus, even when a system failure due to a power failure or the like occurs during operation in the flash memory requiring a long time for writing operation and erasure operation, the bus information on a predetermined number of statuses immediately before the system failure is recorded in the auxiliary nonvolatile memory. Hence, the bus information recorded in the auxiliary nonvolatile memory is analyzed after system restoration to thereby determine a state of operation at the time of occurrence of the system failure, detect abnormality in data in the flash memory, and restore the flash memory to a normal storage state.
The conventional electronic device including a flash memory has the data protection function as described above. In the former method of using a check sum or CRC code, a state of operation at the time of a system failure cannot be detected, and therefore a complex system needs to be constructed to perform processing for system restoration or processing for restoring the data in the flash memory.
In the latter method of storing bus information in the auxiliary nonvolatile memory, it is necessary to analyze the stored bus information, determine a state of operation at the time of a system failure, and restore the data in the flash memory according to the determined state of operation, and a complex system needs to be constructed to perform the data restoration processing.